Conditions | 2 |
Paths | 3 |
Total Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | import {each} from './utils' |
||
23 | export default function aliasesMixinMaker(options) { |
||
24 | let isEnabled |
||
25 | if (typeof options === 'boolean') { |
||
26 | isEnabled = () => options |
||
27 | } else { |
||
28 | isEnabled = key => { |
||
29 | return key in options && options[key] |
||
30 | } |
||
31 | } |
||
32 | |||
33 | const mixin = { |
||
34 | computed: {}, // variables |
||
35 | methods: {} |
||
36 | } |
||
37 | |||
38 | each(variables, (getter, key) => { |
||
39 | if (isEnabled(key)) { |
||
1 ignored issue
–
show
|
|||
40 | mixin.computed[`$${key}`] = getter |
||
41 | } |
||
42 | }) |
||
43 | |||
44 | each(methods, (caller, key) => { |
||
45 | if (isEnabled(key)) { |
||
1 ignored issue
–
show
|
|||
46 | mixin.methods[`$${key}`] = caller |
||
47 | } |
||
48 | }) |
||
49 | |||
50 | return mixin |
||
51 | } |
||
52 |